<?php
/**
 * 菜单列表查询参数
 *
 * @author: WangBin
 * @date: 2021/7/26
 * @mail: <849850352@qq.com>
 */
namespace App\Params\Backend;

use App\Params\Param;

class MenuListParams extends Param
{
    public $name = '';
    public $page = 1;
    public $page_size = 20;
    public $with_tree = 0;
    public $level = 0;
    public $fields = ['*'];
    public $user_id;

    public function rules()
    {
        return [
            'name' => 'nullable|string',
            'page' => 'numeric',
            'page_size' => 'numeric',
            'with_tree' => 'numeric',
            'level' => 'numeric',
            'fields' => 'array',
            'user_id' => 'required|integer'
        ];
    }

    /**
     * @return mixed
     */
    public function getUserId()
    {
        return $this->user_id;
    }

    /**
     * @param mixed $user_id
     */
    public function setUserId($user_id): void
    {
        $this->user_id = $user_id;
    }

    /**
     * @return array
     */
    public function getFields(): array
    {
        return $this->fields;
    }

    /**
     * @param array $fields
     */
    public function setFields(array $fields): void
    {
        $this->fields = $fields;
    }

    /**
     * @return int
     */
    public function getLevel(): int
    {
        return $this->level;
    }

    /**
     * @param int $level
     */
    public function setLevel(int $level): void
    {
        $this->level = $level;
    }

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name ?? '';
    }

    /**
     * @param string $name
     */
    public function setName(string $name): void
    {
        $this->name = $name;
    }

    /**
     * @return int
     */
    public function getPage(): int
    {
        return $this->page > 0 ? $this->page - 1 : 0;
    }

    /**
     * @param int $page
     */
    public function setPage(int $page): void
    {
        $this->page = $page;
    }

    /**
     * @return int
     */
    public function getWithTree(): int
    {
        return $this->with_tree;
    }

    /**
     * @param int $with_tree
     */
    public function setWithTree(int $with_tree): void
    {
        $this->with_tree = $with_tree;
    }

    /**
     * @return int
     */
    public function getPageSize(): int
    {
        return $this->page_size;
    }

    /**
     * @param int $page_size
     */
    public function setPageSize(int $page_size): void
    {
        $this->page_size = $page_size;
    }
}